<template>
        <div class="record">
                <el-table :data="changeData" border stripe>
                        <el-table-column label="合同名称" align="center" >
                                <template slot-scope="scope">
                                        {{scope.row.easylifeContractInfo.contractName}}
                                </template>
                        </el-table-column>
                        <el-table-column label="合同编号" prop="contractCode" align="center" ></el-table-column>
                        <el-table-column label="版本号"  align="center" >
                                <template slot-scope="scope">
                                        V{{scope.row.contractVersion}}
                                </template>
                        </el-table-column>
                        <el-table-column label="状态" prop="hisStatus" align="center" :formatter="initStatus"></el-table-column>
                        <el-table-column label="审核不通过意见" prop="approvalOpinion" align="center" ></el-table-column>
                        <el-table-column label="更新人" prop="createUserName" align="center" ></el-table-column>
                        <el-table-column label="更新时间" prop="createTime" align="center" :formatter="initTime"></el-table-column>
                        <el-table-column label="操作" align="center" >
                                <template slot-scope="scope">
                                        <el-button type="text" @click="lookdetail(scope.row.contractId)">详情</el-button>
                                </template>
                        </el-table-column>
                </el-table>
        </div>
</template>

<script>
import api from '@/api/apiPath'
export default {
        data(){
                return {
                        changeData:[],
                        contractInfo:""
                }
        },
        methods:{
                loadChangeInfo(){//合同变更列表
                        this.axios.get(api.CHANGEINFO+"/"+this.$route.query.contractId).then((res)=>{
                                if(res.data.code==200){
                                        this.changeData=res.data.data;
                                        this.contractInfo=res.data.dataeasylifeContractInfo;
                                }
                        }).catch((error)=>{
                                console.log(error);
                        })
                },
                initTime(row, column, cellValue, index){
                        return this.getTimeString(cellValue)
                },
                initStatus(row, column, cellValue, index){
                        if(cellValue==0){
                                return "已生效"
                        }
                        if(cellValue==1){
                                return "未生效"
                        }
                },
                getTimeString (timestamp) {
                        if (timestamp) {
                                const time = new Date(timestamp)
                                let dateStr = ''
                                const year = time.getFullYear()
                                const month = String(time.getMonth() + 1).length === 1 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1)
                                const day = String(time.getDate()).length === 1 ? '0' + time.getDate() : time.getDate()
                                dateStr = year + '-' + month + '-' + day
                                let timeStr = ''
                                const hours = time.getHours()
                                const hh = String(hours).length === 1 ? '0' + hours : hours
                                const minutes = time.getMinutes()
                                const mm = String(minutes).length === 1 ? '0' + minutes : minutes
                                const seconds = time.getSeconds()
                                const ss = String(seconds).length === 1 ? '0' + seconds : seconds
                                timeStr = `${hh}:${mm}:${ss}`
                                // timeStr = `${hh}:${mm}`
                                return dateStr + ' ' + timeStr
                                // return dateStr
                        } else {
                                return ''
                        }
                },
                lookdetail(id){
                        this.$router.push({
                                path:"/contractaddoredit",
                                query:{
                                        type:"look",
                                        contractId:id
                                }
                        })
                }
        },
        mounted(){
                this.loadChangeInfo()
        }
}
</script>

<style lang="css" scoped>
</style>
